package com.yzyz.utils.json;

import java.util.Date;
import java.util.ArrayList;
import java.util.List;

import net.sf.json.JsonConfig;

import com.yzyz.bean.region.RegionBean;
import com.yzyz.bean.scenic.ScenicBean;
import com.yzyz.utils.json.processor.DateProcessor;

public class JSONRegion extends JSONBase {

	private static final long serialVersionUID = -9197169375858638051L;
	
	private RegionBean regionBean;
	
	public JSONRegion(RegionBean regionBean){
		super(regionBean);
		this.regionBean = regionBean;
		super.setLeaf(false);
	}
	
	public List<JSONBase> getChildren(){
		List<JSONBase> list = new ArrayList<JSONBase>();
		for(ScenicBean attractions: this.regionBean.getScenics()) {
			JSONAttractions ja = new JSONAttractions(attractions);
			list.add(ja);
		}
		return list;
	}
	
	public static JsonConfig getConfig(String excludes[] ){
		JsonConfig config = new JsonConfig();
		config.registerJsonValueProcessor(Date.class,new DateProcessor());
		if(excludes == null || excludes.length == 0) {
			excludes  = new String []{"baseBean"};
		} else {
			config.setExcludes(excludes);
		}
		
		
		return config;
	}
	
}
